<!DOCTYPE html>
<html lang="en">
	<head>
		<meta charset="UTF-8">
		<meta http-equiv="X-UA-Compatible" content="IE=edge">
		<meta name="viewport" content="width=device-width, initial-scale=1.0">
		<link rel="stylesheet" href="./framework/font-awesome-4.7.0/css/font-awesome.min.css">
		<link rel="stylesheet" href="./framework/reset.css">
		<link rel="stylesheet" href="./css/login.css">
		<title>东软环保公众监督系统-网格员端</title>
		<script src="js/base.js"></script>
	</head>
	<body>
		<!-- 总容器 -->
		<div class="wrapper">
			<header>
				<img src="./img/header.png">
			</header>

			<h1>东软环保公众监督平台-网格员端</h1>

			<div class="login">
				<div class="login-input">
					<i class="fa fa-user-o"></i>
					<input id="gmCode" type="text" placeholder="请输入登录编码">
				</div>
				<div class="login-input">
					<i class="fa fa-key"></i>
					<input id="password" type="password" placeholder="请输入登录密码">
				</div>
				<div class="btn" onclick="login()">登录</div>
			</div>

			<footer>
				<img src="./img/bottom.png">
			</footer>
		</div>
	</body>
</html>
<script>
	function login() {
		let gmCode = document.getElementById("gmCode").value;
		let password = document.getElementById("password").value;
		let url = "http://localhost:8080/gridmember/SignIn"
		let json = {};
		json.gmCode = gmCode;
		json.password = password;
		rest(url, "post", json, function(r) {
			if (r.ok) {
				let token = r.data.token;
				localStorage.setItem("token", token);
				localStorage.setItem("gmId", r.data.gmId);
				alert("登录成功");
				location.href = 'feedbackList.html';
			} else {
				alert("登录失败");
			}
		})
	}
</script>